package cn.hd.service.impl;

import cn.hd.dao.LicenseDao;
import cn.hd.entity.Fileupload;
import cn.hd.entity.License;
import cn.hd.service.LicenseService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class LicenseServiceImpl implements LicenseService {
    @Autowired
    private LicenseDao licenseDao;

    @Override
    public PageInfo<License> selectAllFenYeLicense(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<License> licenses = licenseDao.selectAllLicense();
        PageInfo<License> pageInfo=new PageInfo<>(licenses);
        return pageInfo;
    }

    @Override
    public int addFileuploadLicense(@Param("licenseId")long licenseId, @Param("fileuploadId")long fileuploadId) {
        int i = licenseDao.addFileuploadLicense(licenseId, fileuploadId);
        return i;
    }

    @Override
    public Fileupload selectLicenseById(long licenseId) {
        Fileupload fileupload = licenseDao.selectLicenseById(licenseId);
        return fileupload;
    }

    @Override
    public int deleteFileuploadLicense(long licenseId) {
        int i = licenseDao.deleteFileuploadLicense(licenseId);
        return i;
    }

    @Override
    public License selectLicenseByLicenseId(long license_id) {
        License license = licenseDao.selectLicenseByLicenseId(license_id);
        return license;
    }
}
